﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DeVetma.admin.classes;
using DeVetma.admin.models.managers;
using DeVetma.admin.models.database.metadata;

namespace DeVetma.admin.models.entities
{
    [Entity(table = "Payment")]
    public class Payment
    {
        [EntityField(column = "pID", keyField = true, nullValue = null)]
        public string pID { get; set; }

        [EntityField(column = "pDate", keyField = false, nullValue = null)]
	    public DateTime pDate { get; set; }

        [EntityField(column = "pTotalPayment", keyField = false, nullValue = 0.0)]
	    public decimal pTotalPayment { get; set; }

        [EntityField(column = "pCcNum", keyField = false, nullValue = null)]
	    public string pCcNum { get; set; }

        [EntityField(column = "pCVC", keyField = false, nullValue = null)]
	    public string pCVC { get; set; }

        [EntityField(column = "pExpireDate", keyField = false, nullValue = null)]
	    public string pExpireDate { get; set; }

        [EntityField(column = "pCctype", keyField = false, nullValue = null)]
	    public string pCctype { get; set; }

        [EntityField(column = "pCHolderName", keyField = false, nullValue = null)]
	    public string pCHolderName { get; set; }

        [EntityField(column = "pNewEmail", keyField = false, nullValue = null)]
	    public string pNewEmail { get; set; }

        [EntityField(column = "mID", keyField = true, nullValue = null)]
	    public string mID { get; set; }

        [EntityField(column = "dID", keyField = true, nullValue = null)]
	    public string dID { get; set; }

        [EntityField(column = "oID", keyField = false, nullValue= null)]
        public string oID { get; set; }

        public Order order
        {
            get { return getOrder(); }
            set { this.oID = value.oID; }
        }

        public Member member
        {
            get { return getMember(); }
            set { this.mID = value.mUsername; }
        }

        public Delivery delivery
        {
            get { return getDelivery(); }
            set { this.dID = value.dID; }
        }

        private Delivery getDelivery()
        {
            return new DeliveryManager().get(this.dID);
        }

        private Member getMember()
        {
            return new MemberManager().get(this.mID);
        }

        private Order getOrder()
        {
            return new OrderManager().get(this.oID);
        }
    }
}